﻿<Window x:Class="HeapView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
     Height="350" Width="725">
    <Window.Title>
        <Binding Path="CurrentSetFileName"
                 Converter="{StaticResource WindowNameToTitle}"
                 ConverterParameter="Heap View" />
    </Window.Title>
    <DockPanel>
        <Menu DockPanel.Dock="Top">
            <MenuItem Header="File">
                <MenuItem Name="MenuOpen" Header="Open" Click="MenuOpen_Click" />
                <MenuItem Name="MenuSave" Header="Save" Click="MenuSave_Click" />
                <MenuItem Name="CloseSet" Header="Close Set" Click="CloseSet_Click" />
                <MenuItem Name="MenuPrint" Header="Print" Click="MenuPrint_Click" />
                <MenuItem Name="MenuExportCSV" Header="Export CSV" Click="MenuExportCSV_Click" />
                <MenuItem Name="MenuExportDOCX" IsEnabled="False" Header="Export Word" Click="MenuExportDOCX_Click" />
            </MenuItem>
            <MenuItem Header="Filters">
                <MenuItem Name="MenuFilterType"  Header="Type Name" Click="MenuFilterType_Click" />
            </MenuItem>
            <MenuItem Header="Tools">
                <MenuItem Name="OptionsOpen" Header="Options" Click="OptionsOpen_Click" />
            </MenuItem>
        </Menu>
        <Border BorderBrush="Navy"
                DockPanel.Dock="Left"
                BorderThickness="0,0,1,0"
                Padding="5">
            <DockPanel Width="210">
                <DockPanel LastChildFill="False"
                        DockPanel.Dock="Top">
                    <TextBlock Text="Snapshots"
                                VerticalAlignment="Center"
                               DockPanel.Dock="Left" />

                    <Button Name="AddSnapshotButton" 
                            Content="add" 
                            DockPanel.Dock="Right"
                            Foreground="Blue"
                            BorderBrush="Transparent"
                            BorderThickness="0"
                            Background="Transparent"
                            VerticalAlignment="Center"
                            Cursor="Hand"
                            ToolTip="Click to add new dump heap snapshot"
                            Margin="10,0,10,0"
                            Click="AddSnapshotButton_Click" />
                </DockPanel>
                
                <StackPanel Orientation="Vertical"
                            DockPanel.Dock="Bottom">
                    <Button Name="DumpInfoButton" 
                            Content="Dump Info" 
                            Click="DumpInfoButton_Click" />
                    
                </StackPanel>

                <ListBox ItemsSource="{Binding Path=Snapshots}"
                         HorizontalContentAlignment="Stretch"
                         BorderBrush="Transparent"
                         BorderThickness="0">
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal"
                                    Margin="5">
                                <TextBlock Text="{Binding Path=Name}"
                                           ToolTip="{Binding Path=Name}"
                                           Width="130"
                                       VerticalAlignment="Center" />
                                
                                <Button Name="MoveUp"
                                    Width="20"
                                    Padding="1"
                                    Height="20"
                                    Click="MoveUp_Click"
                                    CommandParameter="{Binding}"
                                    BorderBrush="Transparent"
                                    BorderThickness="0"
                                    Background="Transparent"
                                    Foreground="Red"
                                    Cursor="Hand"
                                    VerticalAlignment="Center"
                                    ToolTip="Click to move this snapshot up in set"
                                    Margin="2,0,0,0" >
                                    <Image Source="../Images/upArrow.png" />
                                </Button>
                                
                                <Button Name="MoveDown"
                                    Width="20"
                                    Padding="1"
                                    Height="20"
                                    Click="MoveDown_Click"
                                    CommandParameter="{Binding}"
                                    BorderBrush="Transparent"
                                    BorderThickness="0"
                                    Background="Transparent"
                                    Foreground="Red"
                                    Cursor="Hand"
                                    VerticalAlignment="Center"
                                    ToolTip="Click to remove this snapshot down in set"
                                    Margin="2,0,0,0" >
                                    <Image Source="../Images/downArrow.png" />
                                    
                                </Button>
                                
                                <Button Name="RemoveSnapshotButton"
                                    Width="20"
                                    Padding="1"
                                    Height="20"
                                    Click="RemoveSnapshotButton_Click"
                                    CommandParameter="{Binding}"
                                    BorderBrush="Transparent"
                                    BorderThickness="0"
                                    Background="Transparent"
                                    Foreground="Red"
                                    Cursor="Hand"
                                    VerticalAlignment="Center"
                                    ToolTip="Click to remove this snapshot from set"
                                    Margin="2,0,0,0" >
                                    <Image Source="../Images/delete.png" />
                                </Button>
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </DockPanel>
        </Border>

        <DataGrid Name="DisplayGrid" 
                  AutoGenerateColumns="False"
                  FontSize="10"
                  AlternatingRowBackground="AliceBlue"
                  CanUserReorderColumns="True"
                  CanUserResizeColumns="True"
                  CanUserResizeRows="True"
                  CanUserSortColumns="True"
                  ItemsSource="{Binding Path=Results}">
            <DataGrid.Columns>
                <DataGridTextColumn 
                            Width="3*"
                            Header="Type Name"
                            Binding="{Binding Path=ClassName, Mode=OneWay}" 
                    />
                <DataGridTextColumn 
                            Width="70"
                            Header="Count"
                            SortMemberPath="CountChangePercent"
                            Binding="{Binding Path=CountString, Mode=OneWay}" 
                            />
                <DataGridTextColumn 
                            Width="30"
                            Header="%"
                            Binding="{Binding Path=CountChangePercent, Mode=OneWay}" 
                            />
                <DataGridTextColumn 
                            Width="70"
                             Header="Size"
                            Binding="{Binding Path=SizeString, Mode=OneWay}"
                    />
                <DataGridTextColumn 
                            Width="30"
                            Header="%"
                            Binding="{Binding Path=SizeChangePercent, Mode=OneWay}" 
                            />
                
                <DataGridTextColumn 
                            Width="70"
                            Header="MT"
                            Binding="{Binding Path=MT}" />
            </DataGrid.Columns>
        </DataGrid>

    </DockPanel>
</Window>
